package jroguelike.main.proto;

import aimozg.joglfw.GLColor;
import jroguelike.main.ArtificialIntelligence;
import jroguelike.main.Attribute;
import jroguelike.main.Creature;
import jroguelike.main.World;
import jroguelike.main.ai.BeastAi;
import jroguelike.main.ai.DummyAi;

public final class CreatureProtos {

	public final Creature player;
	public final Creature feralGhoul;
	public final Creature wanderer;
	public final Creature rat;

	private static void initMain(Creature creature, ArtificialIntelligence ai, int level, char glyph, GLColor fg, String name) {
		creature.glyph = glyph;
		creature.ai = ai.makeClone(creature);
		creature.level = level;
		creature.fg = fg;
		creature.name = name;
	}

	private static void initAttrs(Creature creature, int... attributes) {
		assert attributes.length == Attribute.COUNT;
		System.arraycopy(attributes, 0, creature.attributes, 0, attributes.length);
	}


	@SuppressWarnings({"MagicCharacter"})
	public CreatureProtos(World world) {
		final ArtificialIntelligence DUMMY = new DummyAi();
		final ArtificialIntelligence SAPIENT = DUMMY;// TODO ai
		final ArtificialIntelligence ANIMAL = DUMMY;// TODO ai
		final ArtificialIntelligence BEAST = new BeastAi();// TODO ai

		player = new Creature(world);
		initMain(player, SAPIENT, 1, '@', GLColor.WHITE, "Chosen One");
		initAttrs(player, 6, 6, 6, 6, 6, 6, 6);

		feralGhoul = new Creature(world);
		initMain(feralGhoul, BEAST, 1, 'g', GLColor.OLIVE, "feral ghoul");
		initAttrs(feralGhoul, 4, 3, 4, 1, 1, 6, 5);

		wanderer = new Creature(world);
		initMain(wanderer, SAPIENT, 1, 'w', GLColor.LIGHTGRAY, "wanderer");
		initAttrs(wanderer, 6, 6, 6, 6, 6, 6, 6);

		rat = new Creature(world);
		initMain(rat, ANIMAL, 1, 'r', GLColor.BROWN, "rat");
		initAttrs(rat, 2, 7, 2, 1, 1, 9, 5);
	}
}
